package gold.digger;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC122 {

    /*
     * 简单贪心
     * @return:
     */
    public int maxProfit(int[] prices) {
        if (null == prices || prices.length < 2) {
            return 0;
        }

        int maxProfit = 0, curProfit = 0;
        for (int i = 1; i < prices.length; i++) {
            curProfit = prices[i] - prices[i - 1];
            if (curProfit > 0) maxProfit += curProfit;
        }

        return maxProfit;
    }


    public static void main(String[] args) {
        LC122 an = new LC122();
        String test = "abbbbacd";
    }
}
